package com.farmpost.server.controller;


import com.farmpost.server.pojo.Followed;
import com.farmpost.server.pojo.RespBean;
import com.farmpost.server.service.IFollowedService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author king
 * @since 2022-04-12
 */
@RestController
@RequestMapping("/followed")
public class FollowedController {

    @Autowired
    private IFollowedService iFollowedService;

    @ApiOperation(value = "点击关注")
    @PutMapping("/insertFollowed")
    public RespBean insertFollowed(Integer followedUserId) {
        return iFollowedService.insertFollowed(followedUserId);
    }

    @ApiOperation(value = "取消关注")
    @PostMapping("/cancelFollowed")
    public RespBean cancelFollowed(Integer followedUserId) {
        return iFollowedService.cancelFollowed(followedUserId);
    }

    @ApiOperation(value = "查询关注")
    @GetMapping("/getFollowed")
    public List<Followed> getFollowed() {
        return iFollowedService.getFollowed();
    }

    @ApiOperation(value = "更改关注信息")
    @PostMapping("/updateFollowed")
    public RespBean updateFollowed(@RequestBody Map<String, Object> map) {
        return iFollowedService.updateFollowed(map.get("userId"), map.get("followedUserId"), map.get("status"));
    }
}
